﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Synchronization.ClientServices.IsolatedStorage;
using defaultscope;

namespace iTravel.Silverlight
{
    public partial class Home : Page
    {

        // Executes when the user navigates to this page.
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {

        }

        private defaultscopeOfflineContext context;
// Constructor
public Home()
{
InitializeComponent();
context = new defaultscopeOfflineContext(
"ShoppingList",new Uri("http://localhost/ShoppingList/DefaultScopeSyncService.svc
);
context.CacheController.ControllerBehavior.AddScopeParameters(
DataContext = context;
context.LoadCompleted += context_LoadCompleted;
context.LoadAsync();
}
void context_LoadCompleted(object sender, LoadCompletedEventArgs e)
{
context.CacheController.RefreshAsync();
}
private void ApplicationBarIconButton_Click(object sender, EventArgs e)
{
context.CacheController.RefreshAsync();
}
    }
}